#region

using System;

#endregion


namespace OMS.Deep.Cache
{
	/// <summary>
	/// Common cache interface.
	/// </summary>
	/// <typeparam name="TKey">The key type.</typeparam>
	/// <typeparam name="TValue">The value type.</typeparam>
	public interface ICache<in TKey, TValue> : IDisposable
	{
		/// <summary>
		/// Adds a new key value pair to the cache.
		/// </summary>
		/// <param name="key">The key.</param>
		/// <param name="value">The value.</param>
		void Add(TKey key, TValue value);


		/// <summary>
		/// Tries to get the value identified by the key.
		/// </summary>
		/// <param name="key">The key.</param>
		/// <param name="value">The value.</param>
		/// <returns></returns>
		bool TryGetValue(TKey key, out TValue value);


		/// <summary>
		/// Removes the key value pair from the cache.
		/// </summary>
		/// <param name="key"></param>
		void Remove(TKey key);


		/// <summary>
		/// Removes all values from the cache.
		/// </summary>
		void Clear();


		/// <summary>
		/// Tests whether the cache contains an object with the given key.
		/// </summary>
		/// <param name="key">The key to search for.</param>
		/// <returns>Returns true if the key has been found, otherwise false.</returns>
		bool Contains(TKey key);
	}
}